package com.yanjiali.controller;

import com.yanjiali.feign.SearchEngineServiceFeign;
import com.yanjiali.model.R;
import com.yanjiali.model.req.ObtainTheSearchResultsByPaginationReq;
import com.yanjiali.model.req.SearchPromptReq;
import com.yanjiali.model.resp.ObtainTheSearchResultsByPaginationResp;
import com.yanjiali.model.resp.SearchPromptResp;
import com.yanjiali.service.SearchEngineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Package: com.yanjiali.controller
 * @Author: yanjiali
 * @Created: 2025/4/17 21:29
 */
@Api("搜索引擎控制器")
@RequestMapping("/v1/searchEngines")
@RestController
public class SearchEngineController implements SearchEngineServiceFeign {

    @Autowired
    private SearchEngineService searchEngineService;

    @PostMapping("/getDataList")
    @ApiOperation("分页获取搜索结果接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "obtainTheSearchResultsByPaginationReq", value = "分页获取搜索结果接口参数")
    })
    public R<ObtainTheSearchResultsByPaginationResp> ObtainTheSearchResultsByPagination(@RequestBody ObtainTheSearchResultsByPaginationReq obtainTheSearchResultsByPaginationReq) {
        return searchEngineService.ObtainTheSearchResultsByPagination(obtainTheSearchResultsByPaginationReq);
    }

    @PostMapping("/searchPrompt")
    @ApiOperation("搜索补全接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "searchPromptReq", value = "搜索补全请求参数")
    })
    public R<SearchPromptResp> searchPrompt(@RequestBody SearchPromptReq searchPromptReq) {
        return searchEngineService.searchPrompt(searchPromptReq);
    }

    @Override
    public R removeData(String id) {
        return searchEngineService.removeData(id);
    }
}
